package com.devops.admin.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devops.admin.model.DOSHelmChartTemplate;
import com.devops.admin.service.DOSHelmChartTemplateService;
import com.devops.admin.mapper.DOSHelmChartTemplateMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Dell
* @description 针对表【dos_helm_chart_values_template】的数据库操作Service实现
* @createDate 2023-05-08 11:35:37
*/
@Service
public class DOSHelmChartTemplateServiceImpl extends ServiceImpl<DOSHelmChartTemplateMapper, DOSHelmChartTemplate>
    implements DOSHelmChartTemplateService {

    @Override
    public List<DOSHelmChartTemplate> getChartTemplates(Integer chartId, Integer clusterId) {
        List<DOSHelmChartTemplate> templates = lambdaQuery().eq(DOSHelmChartTemplate::getChartId, chartId)
                .eq(DOSHelmChartTemplate::getClusterId, clusterId)
                .list();
        if (templates.isEmpty()) {
            templates = lambdaQuery().eq(DOSHelmChartTemplate::getChartId, chartId)
                    .isNull(DOSHelmChartTemplate::getClusterId)
                    .list();
        }
        return templates;
    }
}




